{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Install Labelbox\n",
    "\n",
    "Use Python 3.5 and above\n",
    "\n",
    "https://pypi.org/project/labelbox/\n",
    "\n",
    "pip3 install labelbox"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Import & Setup\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import labelbox\n",
    "os.environ[\"LABELBOX_API_KEY\"] = 'your_api_key'\n",
    "lb = labelbox.Client()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Uploading or importing data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Upload data from local filesystem**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Upload complete.\n"
     ]
    }
   ],
   "source": [
    "# Get absolute filepath from the subdirectory\n",
    "local_file_paths = [os.path.abspath(os.path.join(r,file)) for r,d,f in os.walk(\"./sample-data/\") for file in f]\n",
    "\n",
    "#Create a dataset in Labelbox and upload the files\n",
    "dataset = lb.create_dataset(name=\"Tesla dataset upload example\")\n",
    "\n",
    "## Tip: You can use this command to append an existing dataset\n",
    "task = dataset.create_data_rows(local_file_paths)\n",
    "task.wait_till_done()\n",
    "print('Upload complete.')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Import data from cloud**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total number of files to import:  115\n",
      "Import complete.\n"
     ]
    }
   ],
   "source": [
    "# Create a JSON array containing file URLs.\n",
    "cloud_file_paths = ['https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554517_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554518_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-3-top-view.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-S-P90D-102.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-X-front-three-quarter-07.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-tesla-model-x-35-of-161.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017_tesla_model-s_LIFE1_ot_209175_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2018-Tesla-Model-3-front-three-quarter-in-motion.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Bay-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-s-17-of-43.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554517_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554518_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-3-top-view.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-S-P90D-102.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-X-front-three-quarter-07.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-tesla-model-x-35-of-161.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017_tesla_model-s_LIFE1_ot_209175_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2018-Tesla-Model-3-front-three-quarter-in-motion.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Bay-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-s-17-of-43.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554517_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554518_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-3-top-view.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-S-P90D-102.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-X-front-three-quarter-07.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-tesla-model-x-35-of-161.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017_tesla_model-s_LIFE1_ot_209175_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2018-Tesla-Model-3-front-three-quarter-in-motion.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Bay-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-s-17-of-43.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554517_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554518_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-3-top-view.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-S-P90D-102.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-X-front-three-quarter-07.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-tesla-model-x-35-of-161.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017_tesla_model-s_LIFE1_ot_209175_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2018-Tesla-Model-3-front-three-quarter-in-motion.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Bay-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/104836109-p100d-review-5.1910x1000.jpeg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2012_tesla_model-s_sedan_signature-performance_rq_oem_2_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2014_tesla_model-s_sedan_p85_rq_oem_1_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-Tesla-Model-S-P90D-front-three-quarter.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-Tesla-Model-X-75d-rear-three-quarter-in-motion-03.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-Tesla-Model-X-75d-side-profile.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-s-17-of-43.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554517_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554518_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-3-top-view.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-S-P90D-102.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-X-front-three-quarter-07.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-tesla-model-x-35-of-161.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017_tesla_model-s_LIFE1_ot_209175_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2018-Tesla-Model-3-front-three-quarter-in-motion.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2120x920-ms-redsunset-1-1.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Bay-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Profile-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Tesla-Model-3-lead-.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Tesla-Model-X-1.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Tesla-Model3-FINAL.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Tesla_model_3_prototype.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/USC70TSC024B021001.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/White_Cruise-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/download.jpeg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/maxresdefault (1).jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/maxresdefault.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/model-3-mountain-pearl-1.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/model-3-social.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/press05-model-x-profile-doors-open.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/screen-shot-2015-09-01-at-10-11-14-am.png',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/screen-shot-2017-10-26-at-6-54-43-am-e1510873759643.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/tesla-model-3-hero-image.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/tesla-model-3-silver-prototype-promo-shot-headlands.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/tesla-model-x-720x409.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/tesla-model-x-promo-shot-3-2.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/teslamodel3-005.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/twarren_08202017_1939_0003.0.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/104836109-p100d-review-5.1910x1000.jpeg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2012_tesla_model-s_sedan_signature-performance_rq_oem_2_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2014_tesla_model-s_sedan_p85_rq_oem_1_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-Tesla-Model-S-P90D-front-three-quarter.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-Tesla-Model-X-75d-rear-three-quarter-in-motion-03.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-Tesla-Model-X-75d-side-profile.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-s-17-of-43.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554517_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554518_h.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-3-top-view.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-S-P90D-102.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-X-front-three-quarter-07.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-tesla-model-x-35-of-161.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017_tesla_model-s_LIFE1_ot_209175_1280.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2018-Tesla-Model-3-front-three-quarter-in-motion.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2120x920-ms-redsunset-1-1.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Bay-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Profile-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Tesla-Model-3-lead-.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Tesla-Model-X-1.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Tesla-Model3-FINAL.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Tesla_model_3_prototype.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/USC70TSC024B021001.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/White_Cruise-1440.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/download.jpeg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/maxresdefault (1).jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/maxresdefault.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/model-3-mountain-pearl-1.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/model-3-social.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/press05-model-x-profile-doors-open.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/screen-shot-2015-09-01-at-10-11-14-am.png',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/screen-shot-2017-10-26-at-6-54-43-am-e1510873759643.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/tesla-model-3-hero-image.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/tesla-model-3-silver-prototype-promo-shot-headlands.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/tesla-model-x-720x409.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/tesla-model-x-promo-shot-3-2.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/teslamodel3-005.jpg',\n",
    " 'https://storage.googleapis.com/labelbox-example-datasets/tesla/twarren_08202017_1939_0003.0.jpg']\n",
    "\n",
    "print('Total number of files to import: ', len(cloud_file_paths))\n",
    "\n",
    "#Create a dataset in Labelbox \n",
    "dataset = lb.create_dataset(name=\"Tesla dataset import example\")\n",
    "\n",
    "#Create an array of labelbox datarows\n",
    "converted_cloud_file_paths = []\n",
    "for path in cloud_file_paths:\n",
    "    converted_cloud_file_paths.append({labelbox.DataRow.row_data: path})\n",
    "\n",
    "## Tip: You can use this command to append an existing dataset\n",
    "task = dataset.create_data_rows(converted_cloud_file_paths)\n",
    "task.wait_till_done()\n",
    "print('Import complete.')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Import data from cloud and set external ID**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total number of files to import:  115\n",
      "Import complete.\n"
     ]
    }
   ],
   "source": [
    "print('Total number of files to import: ', len(cloud_file_paths))\n",
    "\n",
    "#Create a dataset in Labelbox \n",
    "dataset = lb.create_dataset(name=\"Tesla dataset import example with external ID\")\n",
    "\n",
    "#Create an array of labelbox datarows and set filename as external ID\n",
    "converted_cloud_file_paths = []\n",
    "for path in cloud_file_paths:\n",
    "    converted_cloud_file_paths.append({labelbox.DataRow.row_data: path, labelbox.DataRow.external_id: os.path.basename(path)})\n",
    "\n",
    "## Tip: You can use this command to append an existing dataset\n",
    "task = dataset.create_data_rows(converted_cloud_file_paths)\n",
    "task.wait_till_done()\n",
    "print('Import complete.')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Get all dataset in your account and print uid**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cjhfn5yjt0pka0702rojkb05t\n",
      "cjjomd0dej8dw0747t1gf4aly\n",
      "cjjomdt7xapu00799czurehcu\n",
      "cjly8jlk5wj5b0789clp15sjw\n",
      "cjn6domk8cyw0081360zgmnex\n",
      "cjn6dpjlranpv0971bzczrof6\n",
      "cjn6emdrmaw0s0971w6lv5f3f\n",
      "cjnchpiww0tke0813vu6k6fk4\n",
      "cjnciw3hf4jxz0816epblbvb8\n",
      "cjnciwd524k3w0816m7xnsdei\n",
      "cjncizp4x17ih0813ff3lcau2\n",
      "cjnckc9d71l9c0813ycnrwn9l\n",
      "cjnez74pxo6d208139gm4tdp9\n",
      "cjnky3nhd0rnw0887bjk6e9hd\n",
      "cjnnux0op2qmk08474uy8c9cc\n",
      "cjnnux0op2qml0847lduhzrvw\n",
      "cjnnux0op2qmm08476hat63v4\n",
      "cjnnux0op2qmn08470s0sld9w\n",
      "cjnnux0op2qmo0847ogr5l63h\n",
      "cjnnux0op2qmp0847mhcll8t9\n",
      "cjnnux0op2qmq0847iw74vmdm\n",
      "cjnnux0op2qmr0847t0ymjec5\n",
      "cjnqachvya57k0996pl0b87oe\n",
      "cjnqpio5ol8ni0e898op1w242\n",
      "cjoet4u82it020712k5bdow3z\n",
      "cjohh1v4dv8by0712gcg6ml62\n",
      "cjohhqtguvjmy07124lwlu0y5\n",
      "cjohhstmliehe0738ejl2dw6u\n",
      "cjoozxlsia6y40712wpxtd213\n",
      "cjozb8nvd6o1t0d40ylya0ko7\n",
      "cjp1iuk8fa0at0975a9eethfp\n",
      "cjp2yhokk1ct408489dk3y7k5\n",
      "cjqqzrjm12bx70818o1ny05mp\n",
      "cjqqzubo82u5a07770wry82s4\n",
      "cjqy59yntewzi07778ohn468l\n",
      "cjr2pk7gpw80g0737afos45lo\n",
      "cjr72ys7989vk08965y8fbr59\n",
      "cjr7322ha2umr0797qgmq3fug\n",
      "cjr7326xs8ane0896ftp7oltt\n",
      "cjr732g7jb95z0737ddt234rc\n",
      "cjrle7zc8hfj90b47ukfy9lvf\n",
      "cjrle9ti6hq3608982rtazdoy\n",
      "cjrleasinhg3p0b4793z6xxyi\n",
      "cjrlebpm3hqg208980z0isp1m\n",
      "cjrlt2valtxah0b474544xrds\n",
      "cjrsmih1hhewh0b47w9pyy0ce\n",
      "cjschgqfnitv80812w3qvr0dp\n",
      "cjsdgbrssk2za08125lxbmoou\n",
      "cjsdgc7x9jnjn0728613bz8yv\n",
      "cjsdgsaock1dv0728qcz64o8v\n",
      "cjse2zzqismzl0728suazzlxt\n",
      "cjse30hg5t5gi0812l16af1w7\n",
      "cjsf39ecn0iy80728i9zr12jl\n",
      "cjsggmwmuk7ub0728mi2r6hui\n",
      "cjt968ppa1z1l08691xgb48h4\n",
      "cjt9c4wr14u150797m9a86ftj\n",
      "cjt9k0zc88cdv0903funl2kxv\n",
      "cjta9h4iborpp084739kmoqte\n",
      "cjtae32dmr7sy0700fjimi4nw\n",
      "cju2442sw5cup0993mrjlfpl2\n",
      "cju24r827jokq0855bg3fujpw\n",
      "cju2qj4iw1zaj0801nj0yocew\n",
      "cjvoj1vl5yov20a08fjqu9b7q\n",
      "cjw8cxj9py4kt0a08qlk6qnhg\n",
      "cjwhzmuzc60ol0984l34oxy9r\n",
      "cjwi0q3g35yay0828uf8pqubz\n",
      "cjwjm21sf761f08900a2tmic8\n",
      "cjwtkvrutqm9r0811wmgbxqdw\n",
      "cjxmdpfl66fev0848254fmlwc\n",
      "cjxnyk41enyav0701k4zotfo1\n",
      "cjxqs0nu78ren0701ga5dns7c\n",
      "cjxxr4adkjm7x0846hnm4niaq\n",
      "cjy7kf3o8lzo40846zfd8q9d0\n",
      "cjy7kft0pmzi107380f8hhtwt\n",
      "cjypfnoymonvs0863606ttrrj\n",
      "cjyukucyy7zt10838f52lfeva\n",
      "cjyuqkq3imzrl0721dwbskecz\n",
      "cjz2adzyli4v50a469ax7q6k2\n",
      "cjz2b90zxibcy0a467eeaj8fv\n",
      "cjz3xblvjpozl0721zc36a9jw\n",
      "cjz7wco475hxy07638sgokoid\n",
      "cjz9rwfontpz50763bx4n1bmd\n",
      "cjza7kegn3vrd0794bot6svdr\n",
      "cjzaapweie9pe0a46rsd5agii\n",
      "cjziljf5bzgsk0a4631n3vsj7\n",
      "cjziqf7fwsmzh0701wxdwlx57\n",
      "cjzlwjsstr1pg09446dqnws9o\n",
      "cjzmigywlx58o072117pmkqtk\n",
      "cjzuxdlfor7up0721463sxjyq\n",
      "cjzv7asfhsz0g0838l1mrozsu\n",
      "cjzyd14e1ax1f0a46elyx1lyb\n",
      "ck0blgstt4l9b0944v96hai6f\n",
      "ck0bm56x641930838irsx0240\n",
      "ck0bm8epc2f8c0794giph9y0p\n",
      "ck0bngujw4r530944jxicpte2\n",
      "ck0bzbjisi7us0848x6u33oex\n",
      "ck0c0qia954sa0794bb3pkfq4\n",
      "ck0c2f8gm7bqe0838otrkg942\n",
      "ck0c2y132hzr00a460sjeujua\n"
     ]
    }
   ],
   "source": [
    "for dataset in list(lb.get_datasets())[:]:\n",
    "    print(dataset.uid)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Get all projects in your account and print name & uid**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Image classification ck08mqe2iqzly072171yglspn\n",
      "Retail  ck071b5y54yvk0794i40stwxj\n",
      "ILA demo cjsgltyg1o2kd0812igh0f4eb\n"
     ]
    }
   ],
   "source": [
    "for project in list(lb.get_projects())[:]:\n",
    "    print(project.name, project.uid)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Create a project and attach the dataset**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<Dataset ID: ck08sih943gqb084888jjl0g0>]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "project = lb.create_project(name=\"Created From Pip\")\n",
    "project.datasets.connect(dataset)\n",
    "list(project.datasets())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Delete this project & dataset**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset.delete()\n",
    "project.delete()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Get all datarows within a dataset**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<DataRow {'created_at': '2018-05-21T02:38:40.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-s-17-of-43.jpg', 'uid': 'cjhfn5yjt0pkb0702ofkyt4cv', 'updated_at': '2018-05-21T02:38:40.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:40.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554517_h.jpg', 'uid': 'cjhfn5yjt0pkc0702vi10obbv', 'updated_at': '2018-05-21T02:38:40.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:40.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2016-tesla-model-x_100554518_h.jpg', 'uid': 'cjhfn5yjt0pkd0702q60u2i4f', 'updated_at': '2018-05-21T02:38:40.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:40.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-3-top-view.jpg', 'uid': 'cjhfn5yjt0pke070218t2mioy', 'updated_at': '2018-05-21T02:38:40.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:40.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-S-P90D-102.jpg', 'uid': 'cjhfn5yjt0pkf0702qla7kkm0', 'updated_at': '2018-05-21T02:38:40.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:41.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-Tesla-Model-X-front-three-quarter-07.jpg', 'uid': 'cjhfn5yjt0pkg0702lsaywm7z', 'updated_at': '2018-05-21T02:38:41.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:41.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017-tesla-model-x-35-of-161.jpg', 'uid': 'cjhfn5yjt0pkh0702risxf5rc', 'updated_at': '2018-05-21T02:38:41.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:41.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2017_tesla_model-s_LIFE1_ot_209175_1280.jpg', 'uid': 'cjhfn5yjt0pki0702icnthsie', 'updated_at': '2018-05-21T02:38:41.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:41.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/2018-Tesla-Model-3-front-three-quarter-in-motion.jpg', 'uid': 'cjhfn5yjt0pkj0702gpcy7uln', 'updated_at': '2018-05-21T02:38:41.000Z'}>\n",
      "<DataRow {'created_at': '2018-05-21T02:38:41.000Z', 'external_id': None, 'row_data': 'https://storage.googleapis.com/labelbox-example-datasets/tesla/Red_Bay-1440.jpg', 'uid': 'cjhfn5yjt0pkk07027ua3hscu', 'updated_at': '2018-05-21T02:38:41.000Z'}>\n"
     ]
    }
   ],
   "source": [
    "dataset = lb.get_dataset('cjhfn5yjt0pka0702rojkb05t')\n",
    "for data_row in dataset.data_rows():\n",
    "    print(data_row)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
